package com.suning.sawp.web.controller;

import java.io.IOException;
import java.io.InputStream;
import java.security.Principal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import com.suning.nsfuaa.employee.dto.EmployeeInfo;
import com.suning.sawp.constants.ErrorCodeConstants;
import com.suning.sawp.dto.bi.BiStoreKeeperSaleDataDto;
import com.suning.sawp.dto.common.ReturnMsg;
import com.suning.sawp.dto.mainpush.ClerkTaskAssginReq;
import com.suning.sawp.dto.mainpush.LastestChooseManReqDto;
import com.suning.sawp.dto.mainpush.RankingListDto;
import com.suning.sawp.dto.mainpush.SaleStatisticDto;
import com.suning.sawp.dto.mainpush.StoreCateSaleStatis;
import com.suning.sawp.dto.mainpush.StoreMonSaleDetailDto;
import com.suning.sawp.dto.mainpush.StoreTaskCompleteDto;
import com.suning.sawp.dto.storeman.JsonResult;
import com.suning.sawp.dto.storeman.StoreLoginResultBean;
import com.suning.sawp.dto.storeman.StoreManIndexShowData;
import com.suning.sawp.exception.MobileException;
import com.suning.sawp.intf.store.StoreInfoService;
import com.suning.sawp.intf.storeman.StoreManService;
import com.suning.sawp.service.impl.task.StoreTaskService;
import com.suning.sawp.service.task.dto.BIStoreTask;
import com.suning.sawp.service.task.dto.StaffTaskComm;
import com.suning.sawp.service.task.dto.StoreTaskComm;
import com.suning.sawp.service.task.dto.StoreTaskDetail;
import com.suning.sawp.service.util.BaseContants;
import com.suning.sawp.web.exception.MyGsonView;
import com.suning.vgs.follow.remote.intf.StoreManRemoteService;
import com.suning.vgs.follow.remote.store.ActiveIndicator;
import com.suning.vgs.follow.remote.store.ClerkCustomerDevQuery;
import com.suning.vgs.follow.remote.store.ClerkCustomerDevRetDto;
import com.suning.vgs.follow.remote.store.ShopGuideDto;
import com.suning.vgs.follow.remote.store.StoreManBaseDto;
import com.suning.vgs.follow.remote.store.UpdateHeadPicRetDto;

/**
 * 
 * 店+店员信息业务控制类<br>
 * 〈功能详细描述〉
 *
 * @author 12061818
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
@Controller
@RequestMapping("/storeman")
public class StoreManController extends DjBaseController {

    private static final Logger LOGGER = LoggerFactory.getLogger(StoreManController.class);

    @Resource
    StoreManService storeManService;
    
    @Resource
    StoreInfoService storeInfoService;

    @Autowired
    StoreManRemoteService storeManRemoteService;

    @Autowired
    StoreTaskService storeTaskService;

    /**
     * 门店任务分配展示
     * 
     * @return
     * @param taskNo 门店任务编号
     */
    @RequestMapping(value = "/queryAssignTaskDetail.do")
    public MyGsonView queryTaskDetail(@RequestParam Long taskNo) {
        MyGsonView gsonView = createGsonView();
        StoreTaskDetail detail = storeTaskService.queryTaskDetail(taskNo);
        List<StoreTaskComm> taskComms = storeTaskService.queryTaskComm(taskNo);
        Map<String, Object> data = new HashMap<String, Object>();
        data.put("detail", detail);
        data.put("taskComms", taskComms);
        gsonView.addStaticAttribute(BaseContants.DATA, data);
        return gsonView;
    }

    /**
     * 各个商品的员工分配情况展示
     * 
     * @return
     * @param taskNo 门店任务编号
     */
    @RequestMapping(value = "/queryStaffTaskByUNICode.do")
    public MyGsonView queryStaffTaskByUNICode(@RequestParam Long taskNo, @RequestParam Integer commClassifyCode) {
        MyGsonView gsonView = createGsonView();
        List<StaffTaskComm> staffTaskComms = storeTaskService.queryStaffTaskByUNICode(taskNo, commClassifyCode);
        gsonView.addStaticAttribute(BaseContants.DATA, staffTaskComms);
        return gsonView;
    }

    /**
     * 分配商品给员工
     * 
     * @return
     * @param taskNo 门店任务编号
     */
    @RequestMapping(value = "/assginTask.do")
    public MyGsonView assginTask(@RequestBody ClerkTaskAssginReq assginReq, Principal principal) {
        MyGsonView gsonView = createGsonView();
        storeTaskService.bulkAssginTask(assginReq.getTaskNo(), assginReq.getCommClassifyCode(),
                assginReq.getTaskRespMans());
        // 删除个人首页缓存数据
        storeManService.removeIndexShowDataCache(principal.getName());
        return gsonView;
    }

    /**
     * 
     * 功能描述: <br>
     * 〈功能详细描述〉
     *
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping(value = "/loginValid.do")
    public MyGsonView getStoreManInfo(Principal principal, String deviceName, String djDeviceId,
            HttpServletRequest request) {
        MyGsonView gsonView = new MyGsonView();
        LOGGER.info("loginValid.do deviceName:{}, djDeviceId:{}", deviceName, djDeviceId);
        try {

            String requestIp = getUserIp(request);
            StoreLoginResultBean bean = storeManService.staffLogin(principal.getName(), requestIp, deviceName,
                    djDeviceId);
            gsonView.addStaticAttribute("successFlg", bean.getSuccessFlg());
            gsonView.addStaticAttribute("errorCode", bean.getErrorCode());
            gsonView.addStaticAttribute("errorMsg", bean.getErrorMessage());
            gsonView.addStaticAttribute("retCode", bean.getRetCode());
            gsonView.addStaticAttribute("nginxinfo", bean.getNginxinfo());
            gsonView.addStaticAttribute("ofsinfo", bean.getOfsinfo());
            gsonView.addStaticAttribute("cabinfo", bean.getCabinfo());
            gsonView.addStaticAttribute("impinfo", bean.getImpinfo());
            gsonView.addStaticAttribute("authId", bean.getAuthId());
            gsonView.addStaticAttribute("account", bean.getAccount());
            gsonView.addStaticAttribute("serviceNumIds", bean.getServiceNumIds());
            gsonView.addStaticAttribute("positionList", bean.getPositionList());
            gsonView.addStaticAttribute("orgId", bean.getOrgId());
        } catch (MobileException e) {
            gsonView.addStaticAttribute("successFlg", "0");
            gsonView.addStaticAttribute("errorCode", e.getErrorCode());
            gsonView.addStaticAttribute("errorMsg", e.getMessage());
            LOGGER.error("loginValid.do 失败", e);
        }

        return gsonView;
    }

    /**
     * 
     * 功能描述: 取请求IP<br>
     * 〈功能详细描述〉
     *
     * @param request
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    private String getUserIp(HttpServletRequest request) {
        String ip = request.getHeader("X-Forwarded-For");
        boolean forwardFlag = hasDeepIp(ip);
        if (forwardFlag) {
            ip = request.getHeader("Proxy-Client-IP");
        }
        boolean proxClientFlag = hasDeepIp(ip);
        if (proxClientFlag) {
            ip = request.getHeader("WL-Proxy-Client-IP");
        }
        boolean wlProxyClient = hasDeepIp(ip);
        if (wlProxyClient) {
            ip = request.getHeader("HTTP_CLIENT_IP");
        }
        boolean httpClientFlag = hasDeepIp(ip);
        if (httpClientFlag) {
            ip = request.getHeader("HTTP_X_FORWARDED_FOR");
        }
        boolean httpXforwardFlag = hasDeepIp(ip);
        if (httpXforwardFlag) {
            ip = request.getRemoteAddr();
        }
        return ip;
    }

    /**
     * 
     * 功能描述: 判断IP是否OK<br>
     * 〈功能详细描述〉
     *
     * @param ip
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    private boolean hasDeepIp(String ip) {
        return ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip);
    }

    /**
     * 
     * 功能描述: 获取云导购店员用户活跃度指标<br>
     * 〈功能详细描述〉 （今日被赞数，总计被赞数，今日被咨询数）
     *
     * @param userId
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选) 废弃代码，已不再使用
     */
    @RequestMapping(value = "/getActiveIndicator.do")
    public MyGsonView getActiveIndicator(Principal principal) {
        ReturnMsg<ActiveIndicator> msg = storeManService.getActiveIndicator(principal.getName());
        return setGsonView(msg);
    }

    /**
     * 
     * 功能描述: 获取所有品类信息<br>
     * 〈功能详细描述〉
     *
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping(value = "/getAllProductCatagories.do")
    public MyGsonView getAllProductCatagories() {
        ReturnMsg<List<ShopGuideDto>> msg = storeManService.getAllProductCategories();
        return setGsonView(msg);
    }

    /**
     * 
     * 功能描述: 更新云导购店员用户信息<br>
     * 〈功能详细描述〉
     *
     * @param userId
     * @param imgData
     * @param productCatagories
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping(value = "/updateUserInfo.do")
    public MyGsonView updateUserInfo(Principal principal,
            @RequestParam(value = "productCatagories", required = false) String productCatagories) {
        ReturnMsg<String> msg = storeManService.updateUserInfo(principal.getName(), productCatagories);
        return setGsonView(msg);
    }

    /***
     * 
     * 功能描述: 上传店员头像<br>
     * 〈功能详细描述〉
     *
     * @param userId
     * @param imgData
     * @return
     * @throws IOException
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/uploadHeadPic.do")
    public MyGsonView uploadHeadPic(Principal principal,
            @RequestParam(value = "imgData", required = false) MultipartFile imgData) throws IOException {
        InputStream inputStream = null;
        if (null != imgData) {
            inputStream = imgData.getInputStream();
        }
        ReturnMsg<UpdateHeadPicRetDto> msg = storeManService.uploadHeadPic(principal.getName(), inputStream);
        return setGsonView(msg);
    }

    /**
     * 
     * 功能描述: 获取发展统计信息<br>
     * 〈功能详细描述〉
     *
     * @param bean
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping(value = "getClerkCustomerDevStatistics.do", produces = "application/json; charset=utf-8")
    public MyGsonView getClerkCustomerDevStatistics(ClerkCustomerDevQuery bean, Principal principal) {
        MyGsonView gsonView = createGsonView();
        bean.setClerkNo(principal.getName());
        if (StringUtils.isEmpty(bean.getClerkNo())) {
            return gsonView;
        }
        bean.setQueryType(ClerkCustomerDevQuery.QueryTypeConstants.T_ALL);
        Long total = storeManRemoteService.getClerkCustomerDevStatistics(bean);
        bean.setQueryType(ClerkCustomerDevQuery.QueryTypeConstants.T_LASTDAY);
        Long yestDevNum = storeManRemoteService.getClerkCustomerDevStatistics(bean);
        bean.setQueryType(ClerkCustomerDevQuery.QueryTypeConstants.T_TODAY);
        Long todayDevNum = storeManRemoteService.getClerkCustomerDevStatistics(bean);
        Map<String, Long> map = new HashMap<String, Long>();
        map.put("total", total);
        map.put("todayDevNum", todayDevNum);
        map.put("yestDevNum", yestDevNum);

        JsonResult jsonResult = new JsonResult(map);
        gsonView.addStaticAttribute("retFlag", jsonResult.getRetFlag());
        gsonView.addStaticAttribute("errorCode", jsonResult.getErrorCode());
        gsonView.addStaticAttribute("errorMessage", jsonResult.getErrorMessage());
        gsonView.addStaticAttribute("data", jsonResult.getData());

        return gsonView;
    }

    /**
     * 查询店员发展会员列表
     */
    @RequestMapping(value = "getClerkCustomerDevList.do", produces = "application/json; charset=utf-8")
    public MyGsonView getClerkCustomerDevList(ClerkCustomerDevQuery bean, Principal principal) {
        MyGsonView gsonView = createGsonView();
        bean.setClerkNo(principal.getName());
        if (StringUtils.isEmpty(bean.getClerkNo())) {
            return gsonView;
        }
        List<ClerkCustomerDevRetDto> list = storeManRemoteService.getClerkCustomerDevList(bean);
        JsonResult jsonResult = new JsonResult(list);
        gsonView.addStaticAttribute("retFlag", jsonResult.getRetFlag());
        gsonView.addStaticAttribute("errorCode", jsonResult.getErrorCode());
        gsonView.addStaticAttribute("errorMessage", jsonResult.getErrorMessage());
        gsonView.addStaticAttribute("data", jsonResult.getData());

        return gsonView;
    }

    /**
     * 根据云导购ID查询店员信息
     * 
     * @param cloudGuideIds
     * @return
     */
    @RequestMapping(value = "queryStoreManInfoByCloudGuideIds.do", produces = "application/json; charset=utf-8")
    public MyGsonView queryStoreManInfoByCloudGuideId(String cloudGuideIds) {
        MyGsonView gsonView = createGsonView();
        // 参数为空时,封装提示信息返回
        if (StringUtils.isBlank(cloudGuideIds)) {
            setErrorMsg(gsonView, ErrorCodeConstants.ERR_0001);
        } else {
            // 根据逗号分隔参数
            String[] ids = cloudGuideIds.split(",");
            if (null != ids && ids.length > 0) {
                try {
                    // 调用接口查询店员信息
                    List<StoreManBaseDto> list = storeManRemoteService.queryStoreManBaseInfo(ids);
                    // 不需要的字段设置为null
                    if (null != list && !list.isEmpty()) {
                        for (StoreManBaseDto dto : list) {
                            dto.setGuides(null);
                        }
                    }
                    gsonView.addStaticAttribute(BaseContants.DATA, list);
                } catch (Exception e) {
                    LOGGER.error("StoreManController.queryStoreManInfoByCloudGuideId-" + cloudGuideIds, e);
                    setErrorMsg(gsonView, ErrorCodeConstants.ERR_0002);
                }
            } else {
                setErrorMsg(gsonView, ErrorCodeConstants.ERR_0001);
            }
        }
        return gsonView;
    }

    /**
     * 
     * 功能描述: 获取店+首页数据信息<br>
     * 〈功能详细描述〉
     *
     * @param principal
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/getIndexData.do")
    public MyGsonView getIndexData(Principal principal) {
        MyGsonView gsonView = createGsonView();
        StoreManIndexShowData indexShowData = null;
        try {
            indexShowData = storeManService.getStoreManIndexShowDataNew(principal.getName());
        } catch (Exception e) {
            LOGGER.error("staffId : {}, getIndexData error", principal.getName(), e);
            setErrorMsg(gsonView, ErrorCodeConstants.ERR_0002);
        }
        gsonView.addStaticAttribute(BaseContants.DATA, indexShowData);
        return gsonView;
    }

    /**
     * 
     * 功能描述: 查询英雄榜数据<br>
     * 〈功能详细描述〉
     *
     * @param principal
     * @param categoryCode
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/getHeroRanking.do")
    public MyGsonView getHeroRanking(Principal principal, String categoryCode) {
        MyGsonView gsonView = createGsonView();
        List<RankingListDto> heroRanks = null;
        try {
            heroRanks = storeManService.getHeroListData(principal.getName(), categoryCode);
        } catch (Exception e) {
            LOGGER.error("staffId : {}, getHeroRanking error", principal.getName(), e);
            setErrorMsg(gsonView, ErrorCodeConstants.ERR_0002);
        }
        gsonView.addStaticAttribute(BaseContants.DATA, heroRanks);
        return gsonView;
    }

    /**
     * 
     * 功能描述: 查询销售统计详情<br>
     * 〈功能详细描述〉
     *
     * @param principal
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/getSaleStatistic.do")
    public MyGsonView getSaleStatistic(Principal principal) {
        MyGsonView gsonView = createGsonView();
        try {
            List<SaleStatisticDto> saleStatistic = storeManService.getSaleStatistic(principal.getName());
            gsonView.addStaticAttribute(BaseContants.DATA, saleStatistic);
        } catch (Exception e) {
            LOGGER.error("staffId : {}, getSaleStatistic error", principal.getName(), e);
            setErrorMsg(gsonView, ErrorCodeConstants.ERR_0002);
        }
        return gsonView;
    }

    /**
     * 
     * 功能描述: 门店销售明细<br>
     * 〈功能详细描述〉
     *
     * @param principal
     * @param categoryCode
     * @param sort
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/getStoreSaleDetail.do")
    public MyGsonView getStoreSaleDetail(Principal principal, String categoryCode, int sort, String sortType) {
        MyGsonView gsonView = createGsonView();
        try {
            List<StoreCateSaleStatis> saleStatistic = storeManService.getStoreCateSalestatis(
                    principal.getName(), categoryCode, sort, sortType, 0, 100);
            gsonView.addStaticAttribute(BaseContants.DATA, saleStatistic);
        } catch (Exception e) {
            LOGGER.error("staffId : {}, getStoreSaleDetail error", principal.getName(), e);
            setErrorMsg(gsonView, ErrorCodeConstants.ERR_0002);
        }
        
        return gsonView;
    }

    /**
     * 
     * 功能描述: 保存最近选择人列表<br>
     * 〈功能详细描述〉
     *
     * @param principal
     * @param reqDto
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping(value = "/saveLastestChooseMan.do")
    public MyGsonView saveLastestChooseMan(Principal principal, @RequestBody LastestChooseManReqDto reqDto) {
        MyGsonView gsonView = createGsonView();
        try {
            storeManService.saveLastestChooseMan(principal.getName(), reqDto);
            gsonView.addStaticAttribute(BaseContants.DATA, "");
        } catch (Exception e) {
            LOGGER.error("staffId : {}, saveLastestChooseMan error", principal.getName(), e);
            setErrorMsg(gsonView, ErrorCodeConstants.ERR_0002);
        }
        
        return gsonView;
    }

    /**
     * 
     * 功能描述: 查询主推排行榜<br>
     * 〈功能详细描述〉
     *
     * @param principal
     * @param taskNo
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/getMainpushRankingList.do")
    public MyGsonView getMainpushRankingList(Principal principal, long taskNo) {
        MyGsonView gsonView = createGsonView();
        try {
            List<RankingListDto> rankingList = storeManService.getMainPushRankingList(principal.getName(), taskNo);
            gsonView.addStaticAttribute(BaseContants.DATA, rankingList);
        } catch (Exception e) {
            LOGGER.error("staffId : {}, getMainpushRankingList error", principal.getName(), e);
            setErrorMsg(gsonView, ErrorCodeConstants.ERR_0002);
        }
        
        return gsonView;
    }

    /**
     * 查询门店品类主推任务详情 功能描述: <br>
     * 〈功能详细描述〉
     *
     * @param principal
     * @param categoryCode
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/getStoreMainpushDetail.do")
    public MyGsonView getStoreMainpushDetail(Principal principal, String categoryCode, Long taskNo) {
        MyGsonView gsonView = createGsonView();
        try {
            BIStoreTask storeTask = storeManService.getStoreMainPushDetail(principal.getName(),taskNo, categoryCode);
            gsonView.addStaticAttribute(BaseContants.DATA, storeTask);
        } catch (Exception e) {
            LOGGER.error("staffId : {}, getStoreMainpushDetail error", principal.getName(), e);
            setErrorMsg(gsonView, ErrorCodeConstants.ERR_0002);
        }
        
        return gsonView;
    }

    /**
     * 
     * 功能描述: 门店主推任务商品完成详情<br>
     * 〈功能详细描述〉
     *
     * @param principal
     * @param storeTaskNo
     * @param uniCode
     * @param saleDate
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/getStoreMainPushGoodsComplete.do")
    public MyGsonView getStoreMainPushGoodsComplete(Principal principal, Long taskNo, String goodsUniCode,
            String saleDate, String queryType) {
        MyGsonView gsonView = createGsonView();
        try {
            StoreTaskCompleteDto completeDetails = storeManService.getStoreTaskCompleteDetail(principal.getName(),
                    taskNo, goodsUniCode, saleDate, queryType);
            gsonView.addStaticAttribute(BaseContants.DATA, completeDetails);
        } catch (Exception e) {
            LOGGER.error("staffId : {}, getStoreMainPushGoodsComplete error", principal.getName(), e);
            setErrorMsg(gsonView, ErrorCodeConstants.ERR_0002);
        }
        return gsonView;
    }
    
    /**
     * 
     * 功能描述: 取门店需要分配任务的店员列表<br>
     * 〈功能详细描述〉
     *
     * @param principal
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/getClerksInStore.do")
    public MyGsonView getClerksInStore(Principal principal) {
        MyGsonView gsonView = createGsonView();
        try {
            List<EmployeeInfo> list = storeManService.getClerksInStore(principal.getName());
            gsonView.addStaticAttribute(BaseContants.DATA, list);
        } catch (Exception e) {
            LOGGER.error("staffId : {}, getClerksInStore error", principal.getName(), e);
            setErrorMsg(gsonView, ErrorCodeConstants.ERR_0002);
        }
        return gsonView;
    }
    
    /**
     * 
     * 功能描述: 去门店-品类的最近选择人列表<br>
     * 〈功能详细描述〉
     *
     * @param principal
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/getLastestChooseMans.do")
    public MyGsonView getLastestChooseMans(Principal principal, String categoryCode) {
        MyGsonView gsonView = createGsonView();
        try {
            List<EmployeeInfo> list = storeManService.getLastestChooseMans(principal.getName(), categoryCode);
            gsonView.addStaticAttribute(BaseContants.DATA, list);
        } catch (Exception e) {
            LOGGER.error("staffId : {}, getClerksInStore error", principal.getName(), e);
            setErrorMsg(gsonView, ErrorCodeConstants.ERR_0002);
        }
        return gsonView;
    }
    
    /**
     * 
     * 功能描述: 门店月度销售详情展示<br>
     * 〈功能详细描述〉
     * @param saleMonth 销售月份
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/getStoreMonSales.do")
    public MyGsonView getStoreMonSales(Principal principal) {
        ReturnMsg<List<StoreMonSaleDetailDto>> retMsg = storeManService.getStoreMonSales(principal.getName());
        return setGsonView(retMsg);
    }
    
    /**
     * 
     * 功能描述: 查询店长WAP销售数据<br>
     * 〈功能详细描述〉
     *
     * @param principal
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/getStoreKeeperSaleData.do")
    public MyGsonView getStoreKeeperSaleData(Principal principal) {
        ReturnMsg<BiStoreKeeperSaleDataDto> retMsg = storeManService.getStoreKeeperWapSaleData(principal.getName());
        return setGsonView(retMsg);
    }
    
    /**
     * 
     * 功能描述: 客户端切换角色时，通知POSTS清除登录信息<br>
     * 〈功能详细描述〉
     *
     * @param roleType
     * @param orgId
     * @param positionName
     * @param positionId
     * @param principal
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/updatePositionInfo.do")
    public MyGsonView updatePositionInfo(String roleType,String orgId ,String positionName , String positionId, Principal principal) {
        ReturnMsg<String> retMsg = storeManService.updatePositionInfo(roleType,orgId,positionName,positionId,principal.getName());
        return setGsonView(retMsg);
    }
    
    /**
     * 
     * 功能描述: 登录注销，清除服务端的人员信息数据缓存<br>
     * 〈功能详细描述〉
     *
     * @param principal
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/loginOut.do")
    public MyGsonView staffLoginOut(Principal principal) {
        ReturnMsg<String> retMsg = new ReturnMsg<String>();
        storeManService.removeStoreManAttachInfoCache(principal.getName());
        return setGsonView(retMsg);
    }
}
